package com.warmlight.voicepacket.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.warmlight.voicepacket.R;
import com.warmlight.voicepacket.data.PlaydeatalData;

//import cn.sharesdk.framework.Platform;
//import cn.sharesdk.framework.PlatformActionListener;
//import cn.sharesdk.framework.ShareSDK;
//import cn.sharesdk.tencent.qq.QQ;
//import cn.sharesdk.wechat.moments.WechatMoments;

public class ShareDialog extends Dialog implements View.OnClickListener {
    private Context mContext;
    private PlaydeatalData.DataBean.ShareBean shareBean;
    public ShareDialog(Context context) {
        super(context,R.style.share_dialog);
        mContext = context;
    }

    protected ShareDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        mContext = context;
    }

    public ShareDialog(Context context, int themeResId) {
        super(context, themeResId);
        mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.layout_shareplay);
        Window win = getWindow();
        win.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        win.setAttributes(params);
        setCancelable(true);
        initView();
    }

    private void initView() {
        View ll_sharewx = findViewById(R.id.ll_sharewx);
        View ll_shareqq = findViewById(R.id.ll_shareqq);
        View ll_sharewb = findViewById(R.id.ll_sharewb);
        ll_sharewx.setOnClickListener(this);
        ll_shareqq.setOnClickListener(this);
        ll_sharewb.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
//        switch (view.getId()){
//            case R.id.ll_sharewx:
////                Log.e("onClick: '",Wechat.NAME );
//                share("Wechat");
//                break;
//            case R.id.ll_shareqq:
//                share(QQ.NAME);
//                break;
//            case R.id.ll_sharewb:
//                share(WechatMoments.NAME);
//                break;
//        }
    }

//    private void share(String pn){
//
//        Platform.ShareParams sp = new Platform.ShareParams();
//        sp.setTitle(shareBean.getTitle());
//        sp.setTitleUrl(shareBean.getH5_url()); // 标题的超链接
//        sp.setText(shareBean.getDesc());
//
//        sp.setSite("暖光科技");
//        sp.setSiteUrl(shareBean.getPic_url());
//
//        sp.setUrl(shareBean.getH5_url());
//
//
//        //微信的
//        sp.setImageUrl(shareBean.getPic_url());
//
//        sp.setShareType(Platform.SHARE_WEBPAGE);
//        Platform qzone = ShareSDK.getPlatform (pn);
//// 设置分享事件回调（注：回调放在不能保证在主线程调用，不可以在里面直接处理UI操作）
//        qzone.setPlatformActionListener (new PlatformActionListener() {
//            public void onError(Platform arg0, int arg1, Throwable arg2) {
////                Log.e("onError: ", arg2.toString());
//                //失败的回调，arg:平台对象，arg1:表示当前的动作，arg2:异常信息
//            }
//            public void onComplete(Platform arg0, int arg1, HashMap arg2) {
//                //分享成功的回调
//            }
//            public void onCancel(Platform arg0, int arg1) {
//                //取消分享的回调
//            }
//        });
//// 执行图文分享
//        qzone.share(sp);
//    }
}
